import 'package:appflutterhomeschool/model/parent_get_homeworks_model.dart';
import 'package:appflutterhomeschool/provider/provider_widget.dart';
import 'package:appflutterhomeschool/res/colors.dart';
import 'package:appflutterhomeschool/res/styles.dart';
import 'package:appflutterhomeschool/route/application.dart';
import 'package:appflutterhomeschool/route/routes.dart';
import 'package:appflutterhomeschool/ui/widgets/button_widget.dart';
import 'package:appflutterhomeschool/ui/widgets/my_app_bar.dart';
import 'package:appflutterhomeschool/ui/widgets/widgets.dart';
import 'package:appflutterhomeschool/view_model/academic_sentiment/job_list_status_view_model.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:provider/provider.dart';

///用户： ninetailedfox
///时间： 2020/7/26
///邮箱： 1037438704@qq.com
///功能： 作业列表状态
class JobListStatusPage extends StatelessWidget {
  final String id;

  JobListStatusPage({this.id});

  @override
  Widget build(BuildContext context) {
    return ProviderWidget<JobListStatusViewModel>(
      onModelReady: (value) => value.initView(),
      model: JobListStatusViewModel(context, id),
      builder: (context, viewModel, child) {
        return Scaffold(
          backgroundColor: Colours.gray_ef,
          appBar: MyAppBar2(title: "依依的作业"),
          body: Stack(
            children: <Widget>[
              Positioned(
                left: 0,
                right: 0,
                top: 0,
                bottom: ScreenUtil().setWidth(115),
                child: viewModel.parentGetHomeworkList == null
                    ? Center(child: CircularProgressIndicator())
                    : SingleChildScrollView(
                        child: Column(
                          children: <Widget>[
                            ListView.builder(
                                physics: NeverScrollableScrollPhysics(),
                                shrinkWrap: true,
                                itemCount:
                                    viewModel.parentGetHomeworkList.length,
                                itemBuilder: listItem)
                          ],
                        ),
                      ),
              ),
              Positioned(
                bottom: 0,
                left: 0,
                right: 0,
                child: ButtonWidget().rectangleButtonWidget(
                    bgColor: Colors.white,
                    textStyle: TextStyles.textDark43,
                    buttonName: "有疑问",
                    onPressed: () {
                      Navigator.pop(context);
                    }),
              )
            ],
          ),
        );
      },
    );
  }

  Widget listItem(context, index) {
    JobListStatusViewModel viewModel = Provider.of(context);
    ParentGetHomeworksModel parentGetHomeworksModel =
        viewModel.parentGetHomeworkList[index];
    return Container(
      margin: EdgeInsets.only(
          left: ScreenUtil().setWidth(35),
          right: ScreenUtil().setWidth(35),
          top: ScreenUtil().setWidth(35)),
      decoration: BoxDecoration(
          color: Colors.white, borderRadius: BorderRadius.circular(10)),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        mainAxisAlignment: MainAxisAlignment.start,
        children: <Widget>[
//                                  Padding(
//                                    padding: EdgeInsets.only(
//                                        left: ScreenUtil().setWidth(35),
//                                        right: ScreenUtil().setWidth(35),
//                                        top: ScreenUtil().setWidth(35)),
//                                    child: Row(
//                                      children: <Widget>[
//                                        Container(
//                                            margin: EdgeInsets.only(right: 5),
//                                            padding: EdgeInsets.only(
//                                                top: 1,
//                                                bottom: 1,
//                                                left: 3,
//                                                right: 3),
//                                            decoration: BoxDecoration(
//                                                color: Colors.blue[50],
//                                                borderRadius:
//                                                    BorderRadius.circular(3)),
//                                            child: Text("语文",
//                                                style: TextStyles.textBlue30)),
//                                        Expanded(
//                                            child: Text("一元二次函数的应用",
//                                                style:
//                                                    TextStyles.textDarkBold43)),
//                                      ],
//                                    ),
//                                  ),
          Container(
            alignment: Alignment.centerLeft,
            padding: EdgeInsets.only(
                left: ScreenUtil().setWidth(35),
                right: ScreenUtil().setWidth(35),
                top: ScreenUtil().setWidth(35)),
            child: ItemTopWidget(
                imageUrl:
                    viewModel.getImageUrl(parentGetHomeworksModel.studentId),
                textContent: parentGetHomeworksModel?.studentName ?? "",
                time: "提交于:${parentGetHomeworksModel.monthDay}",
                visibility: false),
          ),
          Container(
            padding: EdgeInsets.only(
                left: ScreenUtil().setWidth(35),
                right: ScreenUtil().setWidth(35),
                top: ScreenUtil().setWidth(35)),
            child: Text(
              parentGetHomeworksModel?.content ?? "",
              style: TextStyles.textContent31,
            ),
          ),
          ListViewWidget(
            shanchuFujian: false,
            setWidth: 100,
            type: 1,
            listImage: parentGetHomeworksModel?.imgs ?? [],
            onTapIndex: (index) {},
          ),
          Container(
            margin: EdgeInsets.only(
                left: ScreenUtil().setWidth(43),
                bottom: ScreenUtil().setWidth(43)),
            width: ScreenUtil().setWidth(280),
            height: ScreenUtil().setWidth(73),
            child: ButtonWidget().ellipseFrameButton(
                textStyle: TextStyles.textBlue30,
                buttonName: "查看系统作业",
                borderSideColor: Colors.blue,
                widthDouble: ScreenUtil().setWidth(243),
                heightDouble: ScreenUtil().setWidth(115),
                onPressed: () {
                  //进入答题卡
                  Application()
                      .navigatePushToPage(context, Routes.answerSheetPage, {
                    "id": parentGetHomeworksModel?.id,
                  });
                }),
          ),
//          Container(
//            decoration: BoxDecoration(
//                border:
//                    Border(top: BorderSide(color: Colors.grey, width: 0.3))),
//            alignment: Alignment.centerLeft,
//            padding: EdgeInsets.all(ScreenUtil().setWidth(35)),
//            child: ItemTopWidget(textContent: "我", visibility: false),
//          ),
//          Container(
//            alignment: Alignment.centerLeft,
//            padding: EdgeInsets.all(ScreenUtil().setWidth(35)),
//            child: Row(
//              children: [
//                Text(
//                  "作业评分",
//                  style: TextStyles.textGray31,
//                ),
//                Icon(Icons.star, color: Colors.red, size: 15)
//              ],
//            ),
//          ),
//          Container(
//            alignment: Alignment.centerLeft,
//            padding: EdgeInsets.all(ScreenUtil().setWidth(35)),
//            child: Text(
//              "其中第三题、第四题回答错误！请仔细审题后作答。",
//              style: TextStyles.textDark31,
//            ),
//          ),
        ],
      ),
    );
  }
}
